package face.pay.entity;

import face.pay.util.DateUtil;
import face.pay.util.MathUtil;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.Calendar;
import java.util.Date;

/**
 * @Classname CpnCardMessage
 * @Description Administrator
 * @Date 2019/12/16 11:52
 */
@Data
public class CpnCardMessage {

    private Integer id;

    /**
     * 订单id
     */
    private Long orderId;

    /**
     * 优惠券详细信息id
     */
    private Long cardDetailId;

    /**
     * 优惠券详细信息id
     */
    private Long refId;

    /**
     * 消息类型 : GETCARD  CONSUME
     */
    private String type;

    /**
     * 回调次数
     */
    private Integer count;

    /**
     * 0:失败 1:成功
     */
    private Integer status;

    /**
     * 平台消息回调地址
     */
    private String url;

    /**
     * 下一次请求时间
     */
    private String nextTime;

    private String createdTime;

    /**
     * 非表字段
     * @return
     */
    private Long money;


    public String createNextTime() {

        String nextTimeStr = this.nextTime;

        Date nowTime = new Date();

        Date nextDate = new Date();


        if (new Integer(1).equals(this.count)) {

            nextDate = DateUtil.addMinute(nowTime, 1);

         } else if (new Integer(2).equals(this.count)) {

            nextDate = DateUtil.addMinute(nowTime, 5);

        } else if (new Integer(3).equals(this.count)) {

            nextDate = DateUtil.addMinute(nowTime, 10);

        } else if (new Integer(4).equals(this.count)) {
            nextDate = DateUtil.addMinute(nowTime, 30);

        }
        nextTimeStr = DateUtil.dateFormat(nextDate);

        return nextTimeStr;
    }


}
